package com.star.security.context;

import com.star.security.authentication.Authentication;

import javax.servlet.http.HttpServletRequest;

/**
 * token存储
 *
 * @author yangzj
 */
public interface TokenRepository {

    /**
     * 访问令牌 请求?access_token=xxx
     */
    String TOKEN = "access_token";

    /**
     * 保存
     *
     * @param authentication 身份验证
     * @return {@link ResponseToken}
     */
    ResponseToken save(Authentication authentication);

    /**
     * 刷新
     * -只刷新主体principal信息
     *
     * @param authentication 身份验证
     */
    void refresh(Authentication authentication);

    /**
     * 去除
     *
     *
     * @param request HttpServletRequest
     */
    void remove(HttpServletRequest request);

    /**
     * 去除
     *
     * @param authentication 身份验证
     */
    void remove(Authentication authentication);

    /**
     * 获取
     *
     * @param request HttpServletRequest
     * @return {@link Object}
     */
    Authentication get(HttpServletRequest request);

}
